/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLForEntities;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Dries Hoefkens
 */
public class Connectie {
    EntityManagerFactory emf = null;
    EntityManager em = null;  
	String naamPU = "java_reisbureauPU";
  
    public Connectie () {
        
        this.createConnectie();
        
    }
    
     private void createConnectie () {
        if(emf == null) {
          emf = Persistence.createEntityManagerFactory(naamPU);
        }
        if(em == null) {
          em = emf.createEntityManager();
        }
    }
     
    public void closeConnectie () {
        
        if(em != null) {
            em.close();
            //emf.close();
        }
        
    }
     
    public EntityManager getConnectie () {
        
        return em;
        
    }
   
}
